/*
** 3006.c
** 
** Made by (seakage2h)
** Login   <seakage2h@seakage2h-ubuntu>
** 
** Started on  Fri Oct  3 13:11:23 2008 seakage2h
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/

/* #include "3006.h" */
#include <stdio.h>

int main()
{
     int prime_test[1000001];
     int a, d, n;
     int i, j;

     /* INITIALIZATION: time consuming here */
     prime_test[0] = prime_test[1] = 0;
     for(i = 2; i < 1000001; i++)
	  prime_test[i] = 1;
     
     for(i = 2; i < 1000001; i++)
	  if (prime_test[i])
	       for(j = i * 2; j < 1000001; j += i)
		    prime_test[j] = 0;
     
     while(scanf("%d %d %d", &a, &d, &n)){
	  if (a + d + n == 0)
	       break;
	  if (d % 2){		/* d is an odd number */
	       if (a % 2 == 0)	/* a is even */
		    a += d;	/* start from a+d(odd) */
	       else if (prime_test[a+d]){ /* only number 2 is possible */
		    printf("2\n");
		    continue;
	       }
	       while(n){
		    if (prime_test[a])
			 n--;
		    a += 2*d;
	       }
	       printf("%d\n", a - 2*d);
	  }else{		/* d is even */
	       while(n){
		    if (prime_test[a])
			 n--;
		    a += d;
	       }
	       printf("%d\n", a - d);
	  }
	  
     }

     return 0;
}

